package com.learn.string;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class StringTest {

    public static void main(String[] args) {
        byte[] bytes1 = new byte[]{1,2,3,4,5,6,7,8,9};
        String str2 = new String(bytes1, StandardCharsets.UTF_16);
        byte[] bytes2 = str2.getBytes(StandardCharsets.UTF_8);
        System.out.println(Arrays.equals(bytes1, bytes2)); // true

        String dataURL = "...";
        String regex = "^data:image/\\w+;base64,\\S+$";
        System.out.println(dataURL.matches(regex)); // true
        System.out.println(dataURL.matches("^data:image/\\w+;base64,\\S+$"));
    }
    
}
